The deprecated
attribute can be applied with or without explanations, but marking something deprecated
without including
advice as to why it’s deprecated or on what to use instead will lead maintainers to waste time trying to figure those things out - every single time
the warning is encountered.
Noncompliant code example
[[deprecated]] // Noncompliant
void foo1();
__attribute__((deprecated)) // Noncompliant
void foo2();
__declspec(deprecated) // Noncompliant
void foo3();
Compliant solution
[[deprecated("use 'bar' instead")]]
void foo1();
__attribute__((deprecated("use 'bar' instead")))
void foo2();
__declspec(deprecated("use 'bar' instead"))
void foo3();